package com.bw.module_home.visit.model

import com.bw.lib_common.entity.Res
import com.bw.module_home.visit.api.VisitApiService
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject

//class VisitRepository: BaseRepository<VisitApiService>() {
//    override fun createApiServer(): VisitApiService = OkHttpClientManager.retrofitInstance.create(VisitApiService::class.java)
//    suspend fun getVisitList() : Res<VisitEntity> = apiService.getVisitList()
//    suspend fun addVisit(addVisitEntity: AddVisitEntity) : Res<AddVisitEntity> = apiService.addVisit(addVisitEntity)
//
//}

class VisitRepository @Inject constructor() {
    @Inject
    @VisitModule.CommonHomeApi
    lateinit var api: VisitApiService

    fun getVisitList(): Flow<Res<VisitEntity>> = flow {
        emit(api.getVisitList())
    }.flowOn(Dispatchers.IO)
    fun addVisit(addVisitEntity: AddVisitEntity): Flow<Res<AddVisitEntity>> = flow {
        emit(api.addVisit(addVisitEntity))
    }.flowOn(Dispatchers.IO)
}